<template>
    <span>{{ text }}</span>
</template>

<script>

export default {
    name: 'RemoteDictLabel',
    props: {
        dict: String,
        value: [String, Number]
    },
    data() {
        return {
            text: ''
        };
    },
    computed: {

    },
    watch: {
        value: {
            handler() {

            },
            immediate: true
        }
    },
    mounted() {
        this.formatLabel();
    },
    methods: {
        formatLabel() {
            this.$store.dispatch('sysdict/getDictLabel', {
                type: this.dict,
                value: this.value
            }).then(res => {
                this.text = res;
            }).catch(() => {
                this.text = this.value;
            });
        }
    }
};
</script>
